SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROC [dbo].[usp_DanhSachDiTour]
	@MaTour CHAR(20),
	@SoBooking CHAR(15),
	@Loai INT
AS
BEGIN
	IF @Loai = 0
	BEGIN
		SELECT DK.SO_BOOKING, DK.HO_TEN, DK.NGAY_SINH, DK.GIOI_TINH, DK.DIA_CHI, DK.DO_TUOI, DK.LOAI_KHACH, DK.TRANG_THAI_PHONG_DON
		FROM DU_KHACH DK, KHACH_HANG_BOOKING KH
		WHERE KH.SO_BOOKING = DK.SO_BOOKING AND KH.MA_TOUR = @MaTour
		ORDER BY DK.SO_BOOKING ASC
	END  

	ELSE
  
	IF @Loai = 1
	BEGIN	
	  	SELECT DK.HO_TEN, DK.NGAY_SINH, DK.GIOI_TINH, DK.DIA_CHI, DK.DO_TUOI, DK.LOAI_KHACH, DK.TRANG_THAI_PHONG_DON
		FROM DU_KHACH DK, KHACH_HANG_BOOKING KH
		WHERE KH.SO_BOOKING = DK.SO_BOOKING AND kh.SO_BOOKING = @SoBooking
	END      
END

GO
